#include "StdAfx.h"
#include "GraphicPlugin.h"
#include "GraphicPluginImpl.h"
#include "module_specific.h"

GraphicPlugin::GraphicPlugin(void) :
	pImpl( new GraphicPluginImpl )
{
}

GraphicPlugin::~GraphicPlugin(void)
{
}

void GraphicPlugin::getModuleInfo( OUT MODULE_INFO &ModuleInfo ) const
{
	ModuleInfo.strModuleName = PLUGIN_MODULE_PREFIX;
	ModuleInfo.strModuleName.append( "::" );
	ModuleInfo.strModuleName.append( GRAPHIC_PLUGIN_MODULE_NAME_BASE );
	ModuleInfo.VersionHigh = 1;
	ModuleInfo.VersionLow = 0;
}

result GraphicPlugin::initGraphicPlugin( IN const char *pszInput, OUT std::string &strPluginInfo )
{
	return pImpl->initGraphicPlugin( pszInput, strPluginInfo );
}

result GraphicPlugin::queryPlaneInfo( IN const char *pszPlane, OUT std::string &strPlaneInfo )
{
	return pImpl->queryPlaneInfo( pszPlane, strPlaneInfo );
}

/**
 * Is called every time when a new surface of the supported plane is created.
 *
 * The ProductionJobData can be used (together with the Job Id) to make complex
 * operations, e.g. inter-plane processing.
 *
 * The PlaneBitmap can be initialized.
 */
result GraphicPlugin::startPage( 
	IN jobid_t ProductionJobId, 
	IN ProductionJobData &pjd, 
	IN const char *pszPlane, 
	INOUT CBitmapExData &PlaneBitmap )
{
	return pImpl->startPage( ProductionJobId, pjd, pszPlane, PlaneBitmap );
}

/**
 * Is called every time an object matches the extraction area and the surface.
 *
 * For complex operations, the corresponding ProductionJobData structure which
 * is linked with the Job Id can be used for processing, allowing to access all
 * layers.
 *
 * For operations on this plane only, the simple PlaneBitmap can be used.
 *
 * The step (pre / post) is specified in the area.
 */
result GraphicPlugin::processArea( 
	IN jobid_t ProductionJobId, 
	IN ExtractionObject &Object,
//	IN CBitmapExData &SrcBmpData, 
	IN const char *pszArea, 
	INOUT CBitmapExData &PlaneBitmap, 
	OUT std::string &strResult )
{
	return pImpl->processArea( ProductionJobId, Object, pszArea, PlaneBitmap, strResult );
}

result GraphicPlugin::endDocument( IN jobid_t ProductionJobId )
{
	return pImpl->endDocument( ProductionJobId );
}

result GraphicPlugin::preprocessAreas( IN jobid_t ProductionJobId,
									   IN const char *pszPlane,
									   IN const char *pszProfile,
									   INOUT ExtractionAreas &Areas )
{
	return pImpl->preprocessAreas( ProductionJobId, pszPlane, pszProfile, Areas );
}
